import java.sql.*;
import java.util.*;

import by.epam.communalservices.dao.jdbc.JdbcDaoJkhWorker;
import by.epam.communalservices.entity.JkhWorker;
import by.epam.communalservices.exception.JkhDaoException;

public class Main {
    public static void main(String[] args) throws SQLException, ClassNotFoundException {
        System.out.println("Welcome to " + "'Housing and Communal Services' project!");
        Class.forName("org.postgresql.Driver");
        String url = "jdbc:postgresql:JKHBase";
        String username = "postgres";
        String password = "masterkey";
        Connection con = DriverManager.getConnection(url, username, password);

        System.out.println("--------------------------------------------------");
        JdbcDaoJkhWorker worker;
        try {
            worker = new JdbcDaoJkhWorker(con);
            List<JkhWorker> lst = worker.findAll();
            for (JkhWorker w : lst)
                System.out.println(w.toString());
            System.out.println("--------------------------------------------------");
            System.out.println(worker.read(6L));
        } catch (JkhDaoException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}